<!-- 页面外套 -->
<div class="page-wrapper" id="design_budget_build">

    <!-- 数据网格 -->
    <div class="datagrid datagrid-striped" id="design_budget_build_datagrid">

        <!-- 工具条组 -->
        <div class="tool-group">
            <div class="tool-search">
                <div class="im-label">
                    <div class="input-group">
                        <select class="form-control" id="design_budget_build_tool_keys">
                            <option value="1">项目编号</option>
                            <option value="2">项目名称</option>
                            <option value="3">设计师</option>
                        </select>
                        <span class="input-group-addon fix-border fix-padding"></span>
                        <input type="text" class="form-control" id="design_budget_build_tool_search">
                    </div>
                </div>
                <label>
                    <span>预算状态：</span>
                    <select class="form-control" id="design_budget_build_tool_select1">
                        <option value="0">全部</option>
                        <option value="1">制作中</option>
                        <option value="2">设计经理审核中</option>
                        <option value="3">审计审核中</option>
                    </select>
                </label>
                <label>
                    <span>空间类型：</span>
                    <select class="form-control" id="design_budget_build_tool_select2"><!--JS推进--></select>
                </label>
                <label><button class="btn btn-primary" id="design_budget_build_search_btn"><i class="icon icon-search"></i> 搜索</button></label>
                <div class="clearfix"></div>
            </div>
            <div class="tool-deal">
            	<label><button class="btn btn-primary" id="design_budget_build_add_btn"> <i class="icon icon-plus"></i> 新建预算</button></label>
                <div class="clearfix"></div>
            </div>
        </div>
        <!-- tool-group -->

        <div class="datagrid-container"></div>
        <ul class="pager btn-mini" data-elements="prev,pages,next"></ul>
    </div>
    <!-- datagrid -->

    <!-- 新建预算盒子 -->
    <div class="modal modal-for-page fade" aria-hidden="false" id="design_budget_build_add_box">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
                    <h4 class="modal-title">新建预算</h4>
                </div>
                <div class="modal-body">
                    <form class="container form-horizontal">
                        <div class="form-group">
                            <div class="form-group">
                                <label class="col-sm-2 required" for="">预算名称</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                                <label class="col-sm-2 required" for="design_budget_build_add_item">项目选择</label>
                                <div class="col-sm-4">
                                    <select class="form-control" id="design_budget_build_add_item"><!--JS推进--></select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 required" for="">项目联系人</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                                <label class="col-sm-2 required" for="">联系人电话</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 required" for="">项目设计师</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                                <label class="col-sm-2 required" for="">设计师电话</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 required" for="">项目面积</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                                <label class="col-sm-2 required" for="">空间类型</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 required" for="">项目地址</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 required" for="">建筑情况</label>
                                <div class="col-sm-10">
                                    <textarea type="text" class="form-control"></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-2 required" style="text-align:right">
                                    <input type="checkbox" id="">
                                </div>
                                <label class="col-sm-10" for="" style="text-align:left">隐藏验收标准</label>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="design_budget_build_add_submit">提交</button>
                </div>                
            </div>
        </div>
    </div>
    <!-- design_budget_build_add_box -->


    <!-- 预算查看盒子 -->
    <div class="modal modal-for-page fade" aria-hidden="false" id="design_budget_build_show_box">
        <div class="modal-dialog modal-fullscreen">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
                    <h4 class="modal-title">预算查看</h4>
                </div>
                <div class="modal-body">
                    <div class="container">
                        预算查看
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- design_budget_build_show_box -->

    <!-- 预算修改盒子 -->
    <div class="modal modal-for-page fade" aria-hidden="false" id="design_budget_build_edit_box">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
                    <h4 class="modal-title">预算修改</h4>
                </div>
                <div class="modal-body">
                    <form class="container form-horizontal">
                        <div class="form-group">
                            <div class="form-group">
                                <label class="col-sm-2 required" for="">预算名称</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                                <label class="col-sm-2 required" for="">项目选择</label>
                                <div class="col-sm-4">
                                    <select class="form-control" id=""><!--JS推进--></select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 required" for="">项目联系人</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                                <label class="col-sm-2 required" for="">联系人电话</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 required" for="">项目设计师</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                                <label class="col-sm-2 required" for="">设计师电话</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 required" for="">项目面积</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                                <label class="col-sm-2 required" for="">空间类型</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 required" for="">项目地址</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 required" for="">建筑情况</label>
                                <div class="col-sm-10">
                                    <textarea type="text" class="form-control"></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-2 required" style="text-align:right">
                                    <input type="checkbox" id="">
                                </div>
                                <label class="col-sm-10" for="" style="text-align:left">隐藏验收标准</label>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- design_budget_build_edit_box -->
   
    <!-- 预算导出盒子 -->
    <div class="modal modal-for-page fade" aria-hidden="false" id="design_budget_build_export_box">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
                    <h4 class="modal-title">预算导出</h4>
                </div>
                <div class="modal-body">
<!--                     <div class="form-group">
                        <div class="col-sm-2 required" style="text-align:right"><input type="checkbox" id=""></div>
                        <label class="col-sm-10" for="" style="text-align:left">隐藏验收标准</label>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-2 required" style="text-align:right"><input type="checkbox" id=""></div>
                        <label class="col-sm-10" for="" style="text-align:left">隐藏验收标准</label>
                    </div>    
                     -->
                    <form class="container form-horizontal">
                        <div class="form-group"><label><input type="checkbox" id=""> 工程说明</label></div>
                        <div class="form-group"><label><input type="checkbox" id=""> 综合取费表目录</label></div>
                        <div class="form-group"><label><input type="checkbox" id=""> 综合取费表</label></div>
                        <div class="form-group"><label><input type="checkbox" id=""> 工程量清单目录</label></div>
                        <div class="form-group"><label><input type="checkbox" id=""> 工程量清单</label></div>
                        <div class="form-group"><label><input type="checkbox" id=""> 主材清单目录</label></div>
                        <div class="form-group"><label><input type="checkbox" id=""> 主材清单</label></div>
                        <div class="form-group"><label><input type="checkbox" id=""> 辅材清单目录</label></div>
                        <div class="form-group"><label><input type="checkbox" id=""> 辅材清单</label></div>
                        <div class="form-group"><label><input type="checkbox" id=""> 工艺清单目录</label></div>
                        <div class="form-group"><label><input type="checkbox" id=""> 工艺清单</label></div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="design_budget_build_export_submit">提交</button>
                </div>                    
            </div>
        </div>
    </div>
    <!-- design_budget_build_export_box -->

    <!-- 提交初审盒子 -->
    <div class="modal modal-for-page fade" aria-hidden="false" id="design_budget_build_approval_box">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
                    <h4 class="modal-title">提交初审</h4>
                </div>
                <div class="modal-body">
                    <div class="container">
                        提交初审？
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="design_budget_build_approval_submit">提交</button>
                </div>                
            </div>
        </div>
    </div>
    <!-- design_budget_build_approval_box -->

    <!-- 复制预算盒子 -->
    <div class="modal modal-for-page fade" aria-hidden="false" id="design_budget_build_copy_box">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
                    <h4 class="modal-title">复制预算</h4>
                </div>
                <div class="modal-body">
                    <form class="container form-horizontal">
                        <div class="form-group">
                            <div class="form-group">
                                <label class="col-sm-2 required" for="">预算名称</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                                <label class="col-sm-2 required" for="">项目选择</label>
                                <div class="col-sm-4">
                                    <select class="form-control" id=""><!--JS推进--></select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 required" for="">项目联系人</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                                <label class="col-sm-2 required" for="">联系人电话</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 required" for="">项目设计师</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                                <label class="col-sm-2 required" for="">设计师电话</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 required" for="">项目面积</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                                <label class="col-sm-2 required" for="">空间类型</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 required" for="">项目地址</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 required" for="">建筑情况</label>
                                <div class="col-sm-10">
                                    <textarea type="text" class="form-control"></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-2 required" style="text-align:right">
                                    <input type="checkbox" id="">
                                </div>
                                <label class="col-sm-10" for="" style="text-align:left">隐藏验收标准</label>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="design_budget_build_copy_submit">提交</button>
                </div>                
            </div>
        </div>
    </div>
    <!-- design_budget_build_copy_box -->

</div>
<!-- page-wrapper -->
<script>
$(function(){

   $("#design_budget_build_setup_box").modal("show");
    
    //变量声明-----------------------------------------------------------------------------------------------
    var 
    design_budget_build                = $("#design_budget_build"),                   //页面ID
    design_budget_build_datagrid       = $("#design_budget_build_datagrid"),          //数据表格
    //搜索
    design_budget_build_tool_keys      = $("#design_budget_build_tool_keys"),         //搜索类别
    design_budget_build_tool_search    = $("#design_budget_build_tool_search"),       //搜索字段
    design_budget_build_tool_select1   = $("#design_budget_build_tool_select1"),      //下拉选择1
    design_budget_build_tool_select2   = $("#design_budget_build_tool_select2"),      //下拉选择2    
    design_budget_build_search_btn     = $("#design_budget_build_search_btn"),        //搜索按钮
    //新建预算
    design_budget_build_add_box        = $("#design_budget_build_add_box"),           //新建盒子
    design_budget_build_add_btn        = $("#design_budget_build_add_btn"),           //新建按钮
    design_budget_build_add_submit     = $("#design_budget_build_add_submit"),        //新建按钮
    design_budget_build_add_item       = $("#design_budget_build_add_item"),          //新建项目
    //修改
    design_budget_build_edit_box       = $("#design_budget_build_edit_box"),          //修改盒子
    design_budget_build_edit_submit    = $("#design_budget_build_edit_submit"),       //修改提交
    //预算查看
    design_budget_build_show_box       = $("#design_budget_build_show_box"),          //预算查看
    //预算设置
    design_budget_build_setup_box      = $("#design_budget_build_setup_box"),         //设置盒子
    design_budget_build_setup_submit   = $("#design_budget_build_setup_submit"),      //设置提交
    //预算导出
    design_budget_build_export_box     = $("#design_budget_build_export_box"),        //导出盒子
    design_budget_build_export_submit  = $("#design_budget_build_export_submit"),     //导出提交
    //提交初审
    design_budget_build_approval_box   = $("#design_budget_build_approval_box"),      //初审盒子
    design_budget_build_approval_submit= $("#design_budget_build_approval_submit"),   //初审提交
    //复制预算
    design_budget_build_copy_box       = $("#design_budget_build_copy_box"),          //复制盒子
    design_budget_build_copy_btn       = $("#design_budget_build_copy_btn"),          //复制按钮
    design_budget_build_copy_submit    = $("#design_budget_build_copy_submit"),       //复制按钮
    design_budget_build_copy_item      = $("#design_budget_build_copy_item");         //复制项目

    //接口对象-----------------------------------------------------------------------------------------------
    if( window.STATE == "local" ){

        //本地接口
        var design_budget_build_api = {
            datagrid            : LOCAL + "Budget/build_datagrid.json",         //数据表格
            select              : LOCAL + "Test/test_select.json",              //下拉选择
            select_item         : LOCAL + "Budget/build_select_item.json",      //预算项目
            modal_show          : LOCAL + "Test/Business/provider_edit.json",   //修改盒子
            setup_tree          : LOCAL + "Budget/build_setup_tree.json",       //预算书树状图
        }

    } else if ( window.STATE == "route" ){
 
    }

    //数据表格-----------------------------------------------------------------------------------------------
    design_budget_build_datagrid.datagrid({
        height      : zui_datagrid_height(design_budget_build_datagrid),
        sortable    : false,
        cache       : false,
        showRowIndex: true,
        configs     : {
            R0:{className:"text-center"},
            C1:{className:"cell-hidden"}
        },
        states      : {
            pager           : {
                page        : 1,
                recPerPage  : window.REC_PER_PAGE,
            }
        },
        dataSource : {
            cols   : [
                {name:"id",  label:"ID",  width:49},
                {name:"budgetname",     label:"预算名称",  width:150,
                    html:true,
                    valueOperator : {
                        getter : function(dataValue,cell){
                            return `
                            <a class="design_budget_build_show_btn" rowIndex="${cell.rowIndex}">${dataValue}</a>`;
                        }
                    }
                },
                {name:"itemname",       label:"项目名称",  width:150},                
                {name:"itemnumber",     label:"项目编号",  width:80},
                {name:"designer",       label:"设计师",    width:80},
                {name:"costengine",     label:"工程直接费",width:90},
                {name:"costadmin",      label:"管理费用",  width:80},
                {name:"costtax",        label:"税金",      width:80},
                {name:"costtotal",      label:"工程总造价",width:100},
                {name:"discountshow",   label:"显性折扣",  width:80},
                {name:"discounthide",   label:"隐性折扣",  width:80},                
                {name:"discount",       label:"综合折扣",  width:80},
                {name:"costdiscount",   label:"折扣总金额",width:100},
                {name:"spacetype",      label:"空间类型",  width:80},
                {name:"itemstatename",  label:"项目状态",  width:80},
                {name:"budgetstatename",label:"预算状态",  width:80},
                {name:"operate",        label:"预算操作",  width:150,
                    html:true,
                    valueOperator : {
                        getter : function(dataValue,cell){
                            return `
                            <a class="design_budget_build_setup_btn" rowIndex="${cell.rowIndex}">预算书制作</a>
                            <a class="design_budget_build_approval_btn" rowIndex="${cell.rowIndex}">提交初审</a>`;
                        }
                    }
                },
                {name:"operate",        label:"基本操作",   width:150,
                    html:true,
                    valueOperator : {
                        getter : function(dataValue,cell){
                            return `
                            <a class="design_budget_build_edit_btn"   rowIndex="${cell.rowIndex}">修改</a>
                            <a class="design_budget_build_copy_btn" rowIndex="${cell.rowIndex}">复制</a>
                            <a class="design_budget_build_export_btn" rowIndex="${cell.rowIndex}">导出</a>`;
                        }
                    }
                }                
            ],
            remote : function(){
                return {
                    url     : design_budget_build_api.datagrid,
                    type    : "POST",
                    dataType: "json",
                }
            }
        }
    });

    //变量声明-----------------------------------------------------------------------------------------------
    var
    design_budget_build_datagrid_obj     = design_budget_build_datagrid.data("zui.datagrid"),       //表格对象
    design_budget_build_show_btn         = ".design_budget_build_show_btn",                         //预算查看
    design_budget_build_edit_btn         = ".design_budget_build_edit_btn",                         //修改按钮
    design_budget_build_setup_btn       = ".design_budget_build_setup_btn",                         //预算设置
    design_budget_build_export_btn       = ".design_budget_build_export_btn",                       //导出按钮
    design_budget_build_approval_btn     = ".design_budget_build_approval_btn",                     //提交初审
    design_budget_build_copy_btn         = ".design_budget_build_copy_btn";                         //复制

    //下拉选项-----------------------------------------------------------------------------------------------
    //空间类型
    $.ajax({
        url     : design_budget_build_api.select,
        type    : "post",
        dataType: "json",
        data    : {},
        success : function(data){
            if( data.status>0 ){
                var data = data.data;
                var option = "<option value='0'>全部</option>";
                for(var i=0;i<data.length;i++){
                    option += "<option value='"+data[i].id+"'>"+data[i].name+"</option>"
                }
                design_budget_build_tool_select2.html(option);
            }
        }
    });

    //搜索按钮-----------------------------------------------------------------------------------------------
    design_budget_build_search_btn.click(function(){

        //字段整理
        var keyword
        = "?sid="         + design_budget_build_tool_keys.val()
        + "&search="      + design_budget_build_tool_search.val()
        + "&budgetstate=" + design_budget_build_tool_select1.val()
        + "&spacetype="   + design_budget_build_tool_select2.val();

        //GET提交
        zui_datagrid_render(design_budget_build_datagrid_obj,design_budget_build_api.datagrid+keyword);

    });


    //新建预算按钮-----------------------------------------------------------------------------------------------
    design_budget_build_add_btn.click(function(){

        //远程请求
        $.ajax({
            url     : design_budget_build_api.select_item,
            type    : "post",
            dataType: "json",
            data    : {},
            success : function(data){
                if( data.status>0 ){
                    var data = data.data;
                    var option = "";
                    for(var i=0;i<data.length;i++){
                        option += "<option value='"+data[i].id+"'>"+data[i].itemnumber +"--"+ data[i].itemname+"</option>"
                    }
                    //项目选择
                    design_budget_build_add_item.html(option);

                    //面板显示
                    design_budget_build_add_box.modal("show");

                }
            }
        });

    });
    //新建预算提交
    design_budget_build_add_submit.click(function(){

        //远程提交
        $.ajax({
            url     : API.test_response,
            type    : "post",
            dataType: "json",
            data    : { 

            },
            success : function(data){
                if( data.status>0 ){
                    um_tip(data.message);
                    zui_datagrid_reset(design_budget_build_datagrid_obj,design_budget_build_api.datagrid,"clear");
                } else {
                    um_tip(data.message,"1500","text-danger");
                }
            }
        });

    });
 

    //预算修改按钮-----------------------------------------------------------------------------------------------
    $(document).on("click",design_budget_build_edit_btn,function(){

        //面板显示
        design_budget_build_edit_box.modal("show");

    });
    //预算修改提交
    design_budget_build_edit_submit.click(function(){

        //远程提交
        $.ajax({
            url     : API.test_response,
            type    : "post",
            dataType: "json",
            data    : { 

            },
            success : function(data){
                if( data.status>0 ){
                    um_tip(data.message);
                    zui_datagrid_reset(design_budget_build_datagrid_obj,design_budget_build_api.datagrid,"clear");
                } else {
                    um_tip(data.message,"1500","text-danger");
                }
            }
        });

    });

    //预算查看
    $(document).on("click",design_budget_build_show_btn,function(){

        //面板显示
        design_budget_build_show_box.modal("show");

    });

    //预算设置按钮-----------------------------------------------------------------------------------------------
    $(document).on("click",design_budget_build_setup_btn,function(){

        //面板显示
        design_budget_build_setup_box.modal("show");

    });
    //预算设置提交
    design_budget_build_setup_submit.click(function(){

        //远程提交
        $.ajax({
            url     : API.test_response,
            type    : "post",
            dataType: "json",
            data    : { 

            },
            success : function(data){
                if( data.status>0 ){
                    um_tip(data.message);
                    zui_datagrid_reset(design_budget_build_datagrid_obj,design_budget_build_api.datagrid,"clear");
                } else {
                    um_tip(data.message,"1500","text-danger");
                }
            }
        });

    });


    //预算导出按钮-----------------------------------------------------------------------------------------------
    $(document).on("click",design_budget_build_export_btn,function(){

        //面板显示
        design_budget_build_export_box.modal("show");

    });
    //预算导出提交
    design_budget_build_export_submit.click(function(){

        //远程提交
        $.ajax({
            url     : API.test_response,
            type    : "post",
            dataType: "json",
            data    : { 

            },
            success : function(data){
                if( data.status>0 ){
                    um_tip(data.message);
                    zui_datagrid_reset(design_budget_build_datagrid_obj,design_budget_build_api.datagrid,"clear");
                } else {
                    um_tip(data.message,"1500","text-danger");
                }
            }
        });

    });

    //提交初审按钮-----------------------------------------------------------------------------------------------
    $(document).on("click",design_budget_build_approval_btn,function(){

        //ID传值
        design_budget_build_approval_submit.attr("dataId",$(this).attr("rowIndex"));

        //面板显示
        design_budget_build_approval_box.modal("show");

    });
    //提交初审提交
    design_budget_build_approval_submit.click(function(){

        //ID取值
        var data_id = $(this).attr("dataId");

        //远程提交
        $.ajax({
            url     : API.test_response,
            type    : "post",
            dataType: "json",
            data    : { 
                id : data_id
            },
            success : function(data){
                if( data.status>0 ){
                    um_tip(data.message);
                    zui_datagrid_reset(design_budget_build_datagrid_obj,design_budget_build_api.datagrid,"clear");
                } else {
                    um_tip(data.message,"1500","text-danger");
                }
            }
        });

    });

    //复制按钮-----------------------------------------------------------------------------------------------
    $(document).on("click",design_budget_build_copy_btn,function(){

        //ID传值
        design_budget_build_copy_submit.attr("dataId",$(this).attr("rowIndex"));

        //远程请求
        $.ajax({
            url     : design_budget_build_api.select_item,
            type    : "post",
            dataType: "json",
            data    : {},
            success : function(data){
                if( data.status>0 ){
                    var data = data.data;
                    var option = "";
                    for(var i=0;i<data.length;i++){
                        option += "<option value='"+data[i].id+"'>"+data[i].itemnumber +"--"+ data[i].itemname+"</option>"
                    }
                    //项目选择
                    design_budget_build_copy_item.html(option);

                    //面板显示
                    design_budget_build_copy_box.modal("show");

                }
            }
        });

    });
    //复制提交
    design_budget_build_copy_submit.click(function(){

        //ID取值
        var data_id = $(this).attr("dataId");

        //远程提交
        $.ajax({
            url     : API.test_response,
            type    : "post",
            dataType: "json",
            data    : { 
                id : data_id
            },
            success : function(data){
                if( data.status>0 ){
                    um_tip(data.message);
                    zui_datagrid_reset(design_budget_build_datagrid_obj,design_budget_build_api.datagrid,"clear");
                } else {
                    um_tip(data.message,"1500","text-danger");
                }
            }
        });

    });

});//预加载结尾
</script>



 <!-- 预算设置盒子 -->
    <div class="modal modal-for-page fade" aria-hidden="false" data-keyboard="false" id="design_budget_build_setup_box">
        <div class="modal-dialog modal-fullscreen">
            <div class="modal-content">
                <div class="modal-header flex-box">
                    <h4 class="modal-title">预算设置</h4>
                    <span class="text-center flex-son">
                        <a href="#a1">预算书制作 <i class="icon icon-level-down"></i></a> | 
                        <a href="#a2">费用折扣 <i class="icon icon-level-down"></i></a>
                    </span>
                    <button class="btn btn-primary btn-mini" data-dismiss="modal">保存</button>
                </div>
                <div class="modal-body">


<!-- vue开发 -->


<div id="design_budget_build_setup_vue">
    <div class="flex-box">
        <!-- 左侧树状图 -->
        <ul class="tree" style="width:180px;">
            <li v-for='type1 in budget' :key='type1.id' class='open'>
                <div>
                    <span class="pull-left">{{type1.title}}</span>
                    <span class="pull-right">{{type1.count}}</span>
                    <span class="clearfix"></span>
                </div>
                <ul v-if='type1.children'>
                    <li v-for='type2 in type1.children' :key='type2.id' class='open'>
                        <div>
                            <span class="pull-left">{{type2.title}}</span>
                            <span class="pull-right">{{type2.count}}</span>
                            <span class="clearfix"></span>
                        </div>
                        <ul v-if='type2.children'>
                            <li v-for='type3 in type2.children' :key='type3.id' class='open'>
                                <div class="text-primary">
                                    <span class="pull-left">{{type3.title}}</span>
                                    <span class="pull-right">{{type3.count}}</span>
                                    <span class="clearfix"></span>
                                </div>
                            </li>
                        </ul>                        
                    </li>
                </ul>
            </li>
        </ul>
        <!-- tree -->
        <!-- 右侧表格 -->
        <div class="flex-son um_table" style="margin-left:20px;">
            <ul class="um_thead">
                <li>类型</li>
                <li>项目编号</li>
                <li>项目名称</li>
                <li>数量</li>
                <li>单位</li>
                <li>人工单价</li>
                <li>主材单价</li>
                <li>综合单价</li>
                <li>合计(元)</li>
                <li>备注</li>
                <li>工艺</li>
                <li>位置</li>
            </ul>
            <ul class="">
                <li><input type="text"></li>
                <li>项目编号</li>
                <li>项目名称</li>
                <li>数量</li>
                <li>单位</li>
                <li>人工单价</li>
                <li>主材单价</li>
                <li>综合单价</li>
                <li>合计(元)</li>
                <li>备注</li>
                <li>工艺</li>
                <li>位置</li>
            </ul>
           <!--  
            <table class='table table-bordered'>
                <thead>
                    <tr>
                        <th>类型</th>
                        <th>项目编号</th>
                        <th>项目名称</th>
                        <th>数量</th>
                        <th>单位</th>
                        <th>人工单价</th>
                        <th>主材单价</th>
                        <th>综合单价</th>
                        <th>合计(元)</th>
                        <th>备注</th>
                        <th>工艺</th>
                        <th>位置</th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for='type2 in  budget[1]' :key="type2.id">
                        <td colspan="12">{{type2.title}}</td>
                    </tr>
                </tbody> -->
            </table>

        </div>
        <!-- flex-son -->
    </div>
</div>
<style>
.um_table{
    overflow-x : scroll;
    border: 1px solid #ddd;
}
.um_table ul{
    display: block;
    width: 1200px;
    height: 30px;
    overflow: hidden;
    box-sizing:border-box;
}
.um_table ul li{
    box-sizing:border-box;
    display: inline-block;
    padding: 5px;
    width: 100px;
    float: left;
    border:1px solid #ddd;
}
.um_table .um_thead li{
    text-align: center;
    font-weight: bold;
    background: #f5f5f5;
}
</style>

<script>
$(".tree-static").tree();

setTimeout(function(){
    $("#design_budget_build_setup_vue .tree").tree();
    $("#design_budget_build_setup_vue .table").datatable();
},200);

new Vue({
    el  : "#design_budget_build_setup_vue",
    mounted : {
        
    },
    data: {
        "budget" : [
            {
                "id"    : "",
                "title" : "预算统计",
                "count" : "2000",
                "type"  : 0,
                "children" : [
                    {"id":"","title":"家具项目","count":"1000","type":0},
                    {"id":"","title":"水电项目","count":"1000","type":0}            
                ]
            },
            {
                "id"    : "",
                "title" : "预算明细",
                "count" : "6000",
                "type"  : 1,
                "children" : [
                    {
                        "id"    : "",
                        "title" : "会议室",
                        "count" : "4000",
                        "type"  : 2,
                        "children" : [
                            {"id":1,"title":"序工工程","count":"1000","type":3},
                            {"id":2,"title":"拆除工程","count":"1000","type":3},
                            {"id":3,"title":"间隔工程","count":"1000","type":3},
                            {"id":4,"title":"顶面工程","count":"1000","type":3}
                        ]
                    },
                    {
                        "title" : "前台",
                        "count" : "2000",
                        "type"  : 2,
                        "children" : [
                            {"id":1,"title":"序工工程","count":"1000","type":3},
                            {"id":2,"title":"拆除工程","count":"1000","type":3}
                        ]
                    }            
                ]

            }
        ],
    }
});

// $.ajax({
//     url     : LOCAL + "Budget/build_setup_tree.json",
//     type    : "post",
//     success : function(data){
//         var data = um_json(data);
//         $("#test").tree({
//             data        : data,
//             itemCreator : function($li,item){
//                 $li.addClass("open");
//                 $li.append( $("<span>",{
//                         class: 'tree_items type'+item.type,
//                         id: item.id 
//                     }).html(`
//                     <span class='pull-left'> ${item.title}</span> &nbsp;
//                     <span class='pull-right'>${item.count}元</span>
//                     `) 
//                 );
//             },
//         });

//     }
// });

</script>

                    <!-- 传统开发
                    <div class="flex-box" id="a1">
                        <ul class="tree tree-lines with-padding" id="test"></ul>
                        <div class="flex-son" id="right">
                            <ol class="breadcrumb"></ol>
                            <div id="right_table"></div>
                        </div>
                    </div>
                    <style>
                        #test{
                            margin-right:20px;
                        }
                        #test li .tree_items{
                            display: block;
                        }
                        #test li .tree_items:hover{
                            background: #f5f5f5;
                        }
                        #test li{
                            display: block;
                        }
                        #test li .tttt{
                            display: block;
                        }
                        .icon-move{
                            cursor: pointer;
                        }
                        #right tbody{
                            background: #fff;
                        }
                        #right tbody td{
                            width: auto;
                        }
                        #right tbody .gongyi{
                            background: #f5f5f5;
                        }
                        #right input{
                            border: 1px solid;
                            border-color: transparent;
                        }
                        #right input:focus{
                            border-color: #ddd;
                        }
                    </style>
                    <script>

                        $.ajax({
                            url     : LOCAL + "Budget/build_setup_tree.json",
                            type    : "post",
                            success : function(data){
                                var data = um_json(data);
                                $("#test").tree({
                                    data        : data,
                                    itemCreator : function($li,item){
                                        $li.addClass("open");
                                        $li.append( $("<span>",{
                                                class: 'tree_items type'+item.type,
                                                id: item.id 
                                            }).html(`
                                            <span class='pull-left'> ${item.title}</span> &nbsp;
                                            <span class='pull-right'>${item.count}元</span>
                                            `) 
                                        );
                                    },
                                });

                            }
                        });
                        setTimeout(function () {

                            //右击选择
                            var tree_item1 = $(".tree_items.type1");
                            for(var x=0;x<tree_item1.length;x++){
                                tree_item1.eq(x).contextmenu({ 
                                    items: [
                                        {label:"添加区域",onClick:function(){ alert("添加区域");}}
                                    ]
                                })
                            }
                            var tree_item2 = $(".tree_items.type2");
                            for(var y=0;y<tree_item2.length;y++){
                                tree_item2.eq(y).contextmenu({ 
                                    items: [
                                        {label:"添加项目",onClick:function(){ alert("添加项目");}},
                                        {label:"修改",onClick:function(){ alert("修改");}},
                                        {label:"删除",onClick:function(){ alert("删除");}},
                                        {label:"复制",onClick:function(){ alert("复制");}}
                                    ]
                                })
                            }
                            var tree_item3 = $(".tree_items.type3");
                            for(var z=0;z<tree_item3.length;z++){
                                tree_item3.eq(z).contextmenu({ 
                                    items: [
                                        {label:"删除",onClick:function(){ alert("删除");}}
                                    ]
                                })
                            }
                            //拖拽排序
                            var sort_item = $(".type2").next("ul");
                            sort_item.find("li").addClass("text-primary");
                            for(var i=0;i<sort_item.length;i++){
                                sort_item.eq(i).sortable({
                                    selector :"li",
                                });
                            }
                            var temps = `<table class="table table-bordered table-condensed">
                                    <thead>
                                    <tr>
                                        <th>####</th>
                                        <th>/</th>
                                    </tr>
                                    </thead>
                                    <tbody class="table table-bordered">
                                        <tr class="gongyi">
                                            <td><i class="icon icon-move"></i>工艺1</td>
                                            <td><div class="table-toggle">XX</div></td>
                                        </tr>
                                        <tr class="zhucai">
                                            <td><input type="text" value="数据"></td>
                                            <td></td>
                                        </tr>
                                        <tr class="zhucai">
                                            <td><input type="text" value="数据"></td>
                                            <td></td>
                                        </tr>
                                    </tbody>

                                    <tbody class="table table-bordered">
                                        <tr class="gongyi">
                                            <td><i class="icon icon-move"></i>工艺2</td>
                                            <td><div class="table-toggle">XX</div></td>
                                        </tr>
                                        <tr class="zhucai">
                                            <td><input type="text" value="数据"></td>
                                            <td></td>
                                        </tr>
                                        <tr class="zhucai">
                                            <td><input type="text" value="数据"></td>
                                            <td></td>
                                        </tr>
                                    </tbody>
                                </table>
                                `;
                            //点击更新数据
                            tree_item2.click(function(){

                                var text = $(this).find(".pull-left").text();
                                $("#right .breadcrumb").html(`<li>${text}</li>`);
                                $("#right #right_table").html(temps);
                            });
                            //点击更新数据

                            tree_item3.click(function(){
                                var dad = $(this).parent().parent().siblings("span").find(".pull-left").text();
                                var text = $(this).find(".pull-left").text();
                                $("#right .breadcrumb").html(`<li>${dad} > ${text}</li>`);

                                $("#right #right_table").html(temps);
                            });

                        },10);
                        
                        $(document).on("click",".table-toggle",function () {
                            var son = $(this).parent().parent().siblings(".zhucai");
                            son.is(':visible') ? son.hide() : son.show();
                        });
 
                        $("#right").sortable({
                            selector :"tbody",
                            trigger  :".icon",
                            dragCssClass    :"invisible",       //类名添加(子级影子)
                            dropToClass     :"drop-to",         //类名添加(子级影子)
                        });


                    </script>
                        <div style="height:600px;"></div>
                    <hr>
                -->
                <!--
                    <h2 id="a2">费用折扣</h2>
                    <h4>管理费率</h4>
                    <table class="table table-bordered table-condensed">
                        <thead>
                        <tr>
                            <th>左侧固定</th>
                            <th data-type="number" class="flex-col" data-width="200">中间可变</th>
                            <th data-type="date" data-col-class="text-primary">右侧固定</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>小杰</td>
                            <td>12</td>
                            <td>
                                <div>XX</div>
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td>酷拉皮卡</td>
                            <td>17</td>
                            <td>404</td>
                        </tr>
                        </tbody>
                    </table>
                    
                    <h4>其他费率</h4>
                    <table class="table table-bordered table-condensed">
                        <thead>
                        <tr>
                            <th>左侧固定</th>
                            <th data-type="number" class="flex-col" data-width="200">中间可变</th>
                            <th data-type="date" data-col-class="text-primary">右侧固定</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>小杰</td>
                            <td>12</td>
                            <td>
                                <div>XX</div>
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td>酷拉皮卡</td>
                            <td>17</td>
                            <td>404</td>
                        </tr>
                        </tbody>
                    </table>

                    <h4>折扣设置</h4>
                    <div class="form-group">
                        <label class="col-sm-2 required" for="">隐性折扣</label>
                        <div class="col-sm-10">
                            <div class="input-group input-short">
                                <span class="input-group-addon">￥</span>
                                <input class="form-control" type="number">
                                <span class="input-group-addon">折</span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 required" for="">隐性折扣</label>
                        <div class="col-sm-10">
                            <div class="input-group input-short">
                                <span class="input-group-addon">￥</span>
                                <input class="form-control" type="number">
                                <span class="input-group-addon">折</span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 required" for="">优惠金额</label>
                        <div class="col-sm-10">
                            <div class="input-group input-short">
                                <span class="input-group-addon">￥</span>
                                <input class="form-control" type="number">
                                <span class="input-group-addon">折</span>
                            </div>
                        </div>
                    </div>
-->
                </div>
            </div>
        </div>
    </div>
    <!-- design_budget_build_setup_box -->
